iT邦幫忙

0

android dialog

  • 分享至 

  • xImage
  •  
AlertDialog.Builder dialog=new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("123");
dialog.setMessage("456");
dialog.setNegativeButton("no", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Toast.makeText(MainActivity.this, "123", Toast.LENGTH_SHORT).show();
            }
        });
dialog.setPositiveButton("YES",new DialogInterface.OnClickListener() {
           @Override
           public void onClick(DialogInterface arg0, int arg1) {
               TODO Auto-generated method stub
                Toast.makeText(MainActivity.this, "我了解了",Toast.LENGTH_SHORT).show();
           }

       });
       dialog.setNeutralButton("取消",new DialogInterface.OnClickListener() {
            @Override
           public void onClick(DialogInterface arg0, int arg1) {
               // TODO Auto-generated method stub
              Toast.makeText(MainActivity.this, "取消",Toast.LENGTH_SHORT).show();
            }

       });
dialog.show();


////////////////
final String[] dinner={"1","2","3"};
AlertDialog.Builder list=new AlertDiaolog.Builder(MainActivity.this);
list.setTitle("list");
list.setItems(dinner,, new DialogInterface.OnClickListener(){
//            @Override
//
//            //只要你在onClick處理事件內,使用which參數,就可以知道按下陣列裡的哪一個了
//            public void onClick(DialogInterface dialog, int which) {
//                // TODO Auto-generated method stub
//                Toast.makeText(MainActivity.this, "你選的是" + dinner[which], Toast.LENGTH_SHORT).show();
//            }
//        });


  final View v = inflater.inflate(R.layout.alertdialog, null);


//        new AlertDialog.Builder(MainActivity.this)
//                .setTitle("請輸入你的id")
//                .setView(v)
//                .setPositiveButton("確定", new DialogInterface.OnClickListener() {
//                    @Override
//                    public void onClick(DialogInterface dialog, int which) {
//                        EditText editText = (EditText) (v.findViewById(R.id.editText1));
//                        Toast.makeText(getApplicationContext(), "你的id是" +
//
//                                editText.getText().toString(), Toast.LENGTH_SHORT).show();
//                    }
//                })
//                .show();

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言